package com.iris.live.services.covervo;

import com.iris.live.services.common.DateFormatUtils;
import com.iris.live.services.data.models.CustomCarConfigureModel;

import java.util.List;
import java.util.Map;

/**
 * Created by yitianle on 2017/8/17.
 */
public class CustomCarCovert {

    /**
     * 查询map转换model
     * @param mapList
     * @return
     */
    public static CustomCarConfigureModel queryMapConvertModel(List<Map> mapList){
        CustomCarConfigureModel model = new CustomCarConfigureModel();
        if ( null == mapList || mapList.size() <= 0){
            return model;
        }
        Map map = mapList.get(0);
        model.setId(null == map.get("id")?null:Integer.parseInt(String.valueOf( map.get("id"))));
        model.setPermit(null == map.get("permit")?null:String.valueOf( map.get("permit")));
        model.setStoreId(null == map.get("storeId")?null:Integer.parseInt(String.valueOf( map.get("storeId"))));
        model.setTotalPrice(null == map.get("totalPrice")?null:Double.parseDouble(String.valueOf( map.get("totalPrice"))));
        model.setFactPrice(null == map.get("factPrice")?null:Double.parseDouble(String.valueOf( map.get("factPrice"))));
        model.setStatus(null == map.get("status")?null:Integer.parseInt(String.valueOf( map.get("status"))));
        model.setCustomName(null == map.get("customName")?null:String.valueOf( map.get("customName")));
        model.setLastMsrp(null == map.get("lastMsrp")?null:Double.parseDouble(String.valueOf( map.get("lastMsrp"))));
        model.setCreatedTime(null == map.get("createdTime")?null: DateFormatUtils.getFormatDate(String.valueOf( map.get("createdTime")),"yyyy-MM-dd HH:mm:ss"));

        return model;
    }
}
